<template>
  <el-card class="review-card" shadow="hover">
    <div class="review-header">
      <el-avatar :size="50" :src="review.avatar"></el-avatar>
      <div class="review-info">
        <span class="reviewer-name">{{ review.username }}</span>
        <el-rate
            v-model="review.rating"
            disabled
            show-score
            text-color="#ff9900"
            score-template="{value}分">
        </el-rate>
      </div>
    </div>
    <div class="review-content">
      <el-icon class="quote-icon"><ChatLineSquare /></el-icon>
      {{ review.content }}
    </div>
    <div class="review-date">
      {{ dayjs(review.create_time).format('YYYY-MM-DD HH:mm:ss')}}
    </div>
  </el-card>
</template>

<script setup>
import { ChatLineSquare } from '@element-plus/icons-vue'
import dayjs from "dayjs";

defineProps({
  review: {
    type: Object,
    required: true
  }
})
</script>

<style scoped>
.review-card {
  height: 100%;
  transition: all 0.3s ease;
}

.review-card:hover {
  transform: translateY(-3px);
}

.review-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.review-info {
  margin-left: 15px;
  flex: 1;
}

.reviewer-name {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--el-text-color-primary);
  margin-bottom: 8px;
}

.review-content {
  position: relative;
  color: var(--el-text-color-regular);
  font-size: 14px;
  line-height: 1.8;
  padding: 0 0 20px 0;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--el-border-color-lighter);
}

.quote-icon {
  color: var(--el-color-primary);
  font-size: 20px;
  margin-right: 8px;
  vertical-align: middle;
}

.review-date {
  color: var(--el-text-color-secondary);
  font-size: 12px;
  text-align: right;
}
</style>